<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>未知高宽的盒子水平垂直居中</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        #wrap {
            position: relative;
            width: 400px;
            height: 600px;
            background: pink;
            margin: 0 auto;
            text-align: center;
        }
        #inner {
            position: absolute;
            left: 50%;
            top: 50%;
            /*兼容性问题*/
            transform: translate3d(-50%,-50%,0);
            background: deeppink;
        }
    </style>
</head>
<body>
    <div id="wrap">
        <div id="inner">
            test<br/>
            test<br/>
            test<br/>
            test<br/>
            test<br/>
        </div>
    </div>
</body>
</html>
